<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改考勤组')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-group-edit" th:object="${attendanceGroup}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">考勤组名称：</label>
                <div class="col-sm-8">
                    <input name="groupName" th:field="*{groupName}" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">考勤规则：</label>
                <div class="col-sm-8">
                    <select class="form-control noselect2 selectpicker" id="ruleId" name="ruleId" th:with="rule=${@attendanceRule.getRuleList()}" th:field="*{ruleId}" data-none-selected-text="请选择考勤规则" multiple>
                        <option th:each="rule : ${rule}" th:text="${rule.name}" th:value="${rule.id}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                       <textarea name="remark" class="form-control" th:field="*{remark}">
                    </textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var ruleIdValue = [[${attendanceGroup.ruleId}]];
        var prefix = ctx + "school/attendance/group";
        $("#form-group-edit").validate({
            focusCleanup: true
        });
        $(document).ready(function(){
            var value = [];
            if(ruleIdValue != null){
                value = ruleIdValue.split(",");
            }
            console.info(value);
            $('#ruleId').selectpicker('val', value);
        })
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-group-edit').serialize());
            }
        }
    </script>
</body>
</html>